package com.job.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.job.dao.AreaDao;
import com.job.mapper.CityMapper;
import com.job.mapper.ProvinceMapper;
import com.job.pojo.City;
import com.job.pojo.Province;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class AreaDaoImpl implements AreaDao {
    @Resource
    private ProvinceMapper provinceMapper;

    @Resource
    private CityMapper cityMapper;

    @Override
    public List<Province> queryAllProvince() {
        return provinceMapper.selectList(new LambdaQueryWrapper<Province>());
    }

    @Override
    public List<City> queryCityByProvinceId(int provinceId) {
        LambdaQueryWrapper<City> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(City::getProvinceId,provinceId);
        return cityMapper.selectList(wrapper);
    }
}
